package com.yoda.controller;


import com.yoda.dto.MenuDto;
import com.yoda.result.Result;
import com.yoda.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author itcast
 * @since 2023-05-15
 */
@RestController
@RequestMapping("/sys_menu")
public class SysMenuController {
    @Autowired
    private ISysMenuService service;

    /**
     * 菜单修改
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public Result updateMenu(@RequestBody MenuDto dto){
        return service.updateMenu(dto);
    }

    /**
     * 根据id删除菜单
     * @param id
     * @return
     */
    @GetMapping("/del")
    public Result deleteById(String id){
        return service.deleteById(id);
    }

    /**
     * 查询所有菜单
     * @return
     */
    @GetMapping("/allData")
    public Result getMenu(){
        return service.getMenu();
    }

    /**
     * 菜单添加
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public Result addMenu(@RequestBody MenuDto dto){
        return service.addMenu(dto);
    }

    /**
     * 菜单详情
     * @param id
     * @return
     */
    @GetMapping("/rowInfo")
    public Result selectById(String id){
        return service.selectById(id);
    }

}

